# encoding: utf-8
class LoginsController < ApplicationController
  skip_before_filter :require_login, :only => [:login, :dologin]

  def login
    render
  end

  def dologin
    if Digest::MD5.hexdigest(params[:p]) == Mconfig.find_by_cname("password").cvalue
      session[:loggedin]=true
      redirect_to params[:url]
    else
      flash[:error] = "密码输入错误,请重新输入..."
      redirect_to :action => "login"
    end
  end

  def logout
    session[:loggedin]=nil
    redirect_to "/"
  end
end
